
package com.coldchain.gate.ratelimit.config.repository.springdata;

import com.coldchain.gate.ratelimit.config.Rate;
import com.coldchain.gate.ratelimit.config.repository.AbstractRateLimiter;


public class SpringDataRateLimiter extends AbstractRateLimiter {

    private final   IRateLimiterRepository repository;

    public SpringDataRateLimiter(IRateLimiterRepository repository) {
        this.repository = repository;
    }

    @Override
    protected Rate getRate(String key) {
        return this.repository.findOne(key);
    }

    @Override
    protected void saveRate(Rate rate) {
        this.repository.save(rate);
    }

}
